<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>
</head>
<body>
<%
	//取出cookie
	Cookie[] cookies=request.getCookies();
	String uname="";
	String upwd="";
	String autoLogin="";
	
	if(cookies!=null){
	for(Cookie c : cookies){
		if("uname".equals(c.getName())){
			uname=c.getValue();
			
		}if("upwd".equals(c.getName())){
			upwd=c.getValue();
			
		}if("autoLogin".equals(c.getName())){
			autoLogin=c.getValue();
			
		}
		
	}
	}


	pageContext.setAttribute("uname", uname);
	pageContext.setAttribute("upwd", upwd);
	pageContext.setAttribute("autoLogin", autoLogin);
	



%>
	<div>
		<form action="${pageContext.request.contextPath}/login" method="post">
			<div>
				用户名：<input type="text" name="uname" id="uname"
					value="${uname }" /> <span style="color: red;">${error }</span>
			</div>
			<div>
				密码：<input type="password" name="upwd"  id="upwd" value="${upwd }" />
			</div>
			<div>
			记住用户:<input type="checkbox" id="rememberMe" name="rememberMe" value="on" />&nbsp;&nbsp;&nbsp;
			自动登录:<input type="checkbox" id="autoLogin" name="autoLogin" value="on" />
			</div>
			<div>
				<input type="submit" value="登陆" />&nbsp;&nbsp;&nbsp;<button><a href="jsp/register.jsp">注册</a></button>
			</div>
		</form>
	</div>
</body>

<script type="text/javascript">
$(function(){
	var uname=document.getElementById("uname").value;
	var upwd=document.getElementById("upwd").value;
	if(uname!=""){
		document.getElementById("rememberMe").checked="checked";
	}
});
</script>

<script type="text/javascript">
$(function(){
	var auto="${autoLogin}";
	var uname=document.getElementById("uname").value;
	var upwd=document.getElementById("upwd").value;
	if(uname!=""){
		document.getElementById("rememberMe").checked="checked";
	}
	if(auto!="" &&uname!=""&&upwd!=""){
		document.getElementById("autoLogin").checked="checked";
		$("#form").submit();
	}
	
});
</script>
</html>